﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;

namespace Web.Framework.Attributes
{
    public class HandleModelCheckErrorAttribute : HandleErrorAttribute
    {
        public override void OnException(ExceptionContext filterContext)
        {
            //if (filterContext.Exception.GetType() == typeof(ModelCheckException))
            //{
            //    var except = (ModelCheckException)filterContext.Exception;
            //    if (string.IsNullOrEmpty(except.Key))
            //    {
            //        //this.View = "ViewMessage";
            //        //base.OnException(filterContext);
            //        filterContext.HttpContext.Session.Add("ViewMessage", except.Message);
            //        filterContext.HttpContext.Session.Add("ViewMessageType", except.ViewMessageType);
            //    }
            //    else
            //    {
            //        filterContext.HttpContext.Session.Add("ViewMessage", except.Message);
            //        filterContext.HttpContext.Session.Add("ViewMessageType", except.ViewMessageType);
            //        //filterContext.ExceptionHandled = true;
            //        //var area = filterContext.RouteData.DataTokens["Area"].ToString();
            //        //var controller = filterContext.RouteData.Values["Controller"].ToString();
            //        //var action = filterContext.RouteData.Values["Action"].ToString();
            //        //this.View = action;
            //        ////base.OnException(filterContext);
            //        //filterContext.Result = new RedirectToRouteResult(new System.Web.Routing.RouteValueDictionary(new { area = area, controller = controller, action = action }));
            //    }
            //    filterContext.ExceptionHandled = true;
            base.OnException(filterContext);
        }
    }
}
